<html>
<body link="#3366CC" vlink="#3366CC" alink="#3366CC">
<STYLE TYPE="text/css">
a:link { color: #3366CC; text-decoration: underline }
a:active { color: #3366CC; text-decoration: underline }
a:visited { color: #3366CC; text-decoration: underline }
a:hover { color: #FF6699; text-decoration: underline }
</STYLE>
<table border=0 width=1000px height=600px>
<font size=2 face="arial">
<em>
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/../system/config.php';
//Setup
$username = "whatsinvasive"; //flickr user name here
$tagstoignore = array("flickrdate", "zip", "geo:lat", "geo:lon", "geotagged", "shozu", "nolabel");
$mixing = "desc"; // can be random, asc, or desc

// Create new phpFlickr object
require_once($INCLUDE_DIR."phpflickr.helper.php");

if (isset($_GET['tagid']) and ($_GET['tagid'] != ""))
{
	if (isset($_GET['label']) and ($_GET['label'] != ""))
	{

		if (isset($_GET['photoid']) and ($_GET['photoid'] != ""))
		{
			$nolabeltagid = $_GET['tagid'];
			$label = $_GET['label'];
			$photoid = $_GET['photoid'];

			$f->photos_removeTag($nolabeltagid);
			$f->photos_addTags($photoid,$label);

			if( ($label == "invasives") or ($label == "noninvasives") )
			{
				$f->photos_addTags($photoid,"valid");
			}
			//echo $nolabeltagid.$label.$photoid;
		}
	}
}

//only works if user is rocking a name
if (!empty($username)) {
    
    //Determine NSID and get tag arra
    $nsid = $f->people_findByUsername($username);

    $args = array("user_id"=>$nsid['id'], "tags"=>"nolabel");

    $photos = $f->photos_search($args);

    if(count($photos['photo']) == 0)
    {
	echo '<font size=4 face="arial">Sorry, there is nothing to label right now.</font>';
    }
    else
    {

	echo '<table border="0" cellspacing="15" cellpadding="0" width=100% height=400 valign=top>';
	echo '<tr>';
	echo '<td>';

	$photo = $photos['photo'][0];
	$photoinfo = $f->photos_getInfo($photo['id']);
	$nolabeltagid = "";

	foreach ((array)$photoinfo['tags'] as $tags)
	{
		//echo $tags;
		foreach((array)$tags as $tag)
		{
			if($tag['raw'] == "nolabel")
			{
				$nolabeltagid = $tag['id'];
			}
			//echo $tag['id']."<br>";
			//echo $tag['raw']."<br>";
		}
	}

	//echo "No Label Tag ID".$nolabeltagid;

        echo "<img border='0' alt='$photo[title]' "."src=" . $f->buildPhotoURL($photo, "medium") . ">";         
	echo '</td>';	

        echo '<td valign="top">';
	//echo $photo['id'];
	echo '<font size=4 face="arial">Please label the picture for us by clicking on one of the links below.</font><br><br>';
        echo '<font size=2 face="arial">- The image contains <a href="';
	echo '/tagger.php?tagid='.$nolabeltagid.'&label='.'invasives'.'&photoid='.$photo['id'];
	echo '">invasive</a> plants.<br><br>';
        echo '<font size=2 face="arial">- The image contains just regular <a href="';
        echo '/tagger.php?tagid='.$nolabeltagid.'&label='.'noninvasives'.'&photoid='.$photo['id'];
	echo '">non-invasive</a> plant.<br><br>';
        echo '<font size=2 face="arial">- The image is <a href="';
        echo '/tagger.php?tagid='.$nolabeltagid.'&label='.'notvalid'.'&photoid='.$photo['id'];
	echo '">not valid</a> at all (no waste basket or too blurry/dark).<br>';
	echo '</td>';
        echo '</tr></table';


	/*
	foreach ((array)$photos['photo'] as $photo)
	{                                   
	        echo "<a href=\"";
		echo $f->buildPhotoURL($photo, "Square");
		echo "\">";
        	echo "<img border='0' alt='$photo[title]' "."src=" . $f->buildPhotoURL($photo, "Square") . ">";
	        echo "</a>";
    	}
	*/
    }
}
?>
</em></font>
</table>
</body>
</html>
